﻿using Autofac.Core;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using WMS.Seven.Models;
using WMSProject.ChuBoWen;
using WMSProject.SuJiaHao;

namespace WMSProject.Web.Controllers
{
    public class SuJiaHaoController : Controller
    {
        private readonly LossReportingService _lossReportingservice;
        private readonly WarehouseLocationService _wareHouseLocationservice;

        public SuJiaHaoController(LossReportingService lossReportingservice, WarehouseLocationService wareHouseLocationservice)
        {
            _lossReportingservice = lossReportingservice;
            _wareHouseLocationservice = wareHouseLocationservice;
        }

        public IActionResult LossReportingView()
        {
            return View();
        }

        public async Task<ReturnSelect<object>> GetLossReportingList(string?reportNumber, int pageSize, int pageIndex)
        {
            var list = await _lossReportingservice.GetLossReportingList(reportNumber,pageSize, pageIndex);
            return list;
        }

        /// <summary>
        /// 客户添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult LossReportingAddView()
        {
            return View();
        }

        /// <summary>
        /// 报损管理添加
        /// </summary>
        /// <param name="input">客户实体</param>
        /// <returns></returns>
        public async Task<IActionResult> GetCreateLossReporting(CreateLossReportingDTO input)
        {
            var lossReporting = await _lossReportingservice.GetCreateLossReporting(input);
            return Json(new { data = lossReporting, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        ///报损管理删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeleteLossReporting(int id)
        {
            var lossReportingDel = await _lossReportingservice.DeleteLossReporting(id);
            return Json(new { data = lossReportingDel, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 报损管理修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult LossReportingUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 报损管理反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>报损管理信息实体</returns>
        public async Task<IActionResult> GetLossReportingManagement(int id)
        {
            var lossReporting = await _lossReportingservice.GetLossReportingManagement(id);
            return Json(new { data = lossReporting, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 客户信息修改
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateLossReporting(CreateLossReportingDTO input)
        {
            var lossReporting = await _lossReportingservice.UpdateLossReporting(input);
            return Json(new { data = lossReporting, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 库位管理视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseLocationServiceView()
        {
            return View();
        }

        /// <summary>
        /// 获取库位管理列表
        /// </summary>
        /// <param name="pageSize">页容量</param>
        /// <param name="pageIndex">当前页</param>
        /// <returns>返回库位管理</returns>
        public async Task<ReturnSelect<object>> GetWarehouseLocationList(string?locationNumber, string?locationName, int pageSize, int pageIndex)
        {
            var list = await _wareHouseLocationservice.GetWarehouseLocationList(locationNumber,locationName, pageSize, pageIndex);
            return list;
        }

        /// <summary>
        /// 库位管理添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseLocationServiceAddView()
        {
            return View();
        }

        /// <summary>
        /// 报损管理添加
        /// </summary>
        /// <param name="input">客户实体</param>
        /// <returns></returns>
        public async Task<IActionResult> GetCreateWarehouseLocation(CreateWarehouseLocationDTO input)
        {
            var warehouseLocation = await _wareHouseLocationservice.GetCreateWarehouseLocation(input);
            return Json(new { data = warehouseLocation, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        ///报损管理删除
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> DeleteWarehouseLocation(int id)
        {
            var warehouseLocationDel = await _wareHouseLocationservice.DeleteWarehouseLocation(id);
            return Json(new { data = warehouseLocationDel, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 库位管理修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult WarehouseLocationServiceUpdateView()
        {
            return View();
        }

        /// <summary>
        /// 库位管理反填
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回客户信息实体</returns>
        public async Task<IActionResult> GetWarehouseLocationManagement(int id)
        {
            var warehouseLocation = await _wareHouseLocationservice.GetWarehouseLocationManagement(id);
            return Json(new { data = warehouseLocation, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 库位管理修改
        /// </summary>
        /// <param name="id">条件编号</param>
        /// <returns>返回受影响行数</returns>
        public async Task<IActionResult> UpdateWarehouseLocationManagement(CreateWarehouseLocationDTO input)
        {
            var warehouseLocation = await _wareHouseLocationservice.UpdateWarehouseLocationManagement(input);
            return Json(new { data = warehouseLocation, count = 9, code = "0", msg = "" });
        }

        /// <summary>
        /// 可用库存管理视图
        /// </summary>
        /// <returns></returns>
        public IActionResult ProductsView()
        {
            return View();
        }

    }
}
